<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/manage/header.jsp"%>
<div>
	<c:if test="${empty page.records }">
		<h2>没有任何类别，请先添加</h2>&nbsp;&nbsp;
		<a href="${pageContext.request.contextPath}/manage/addCategory.jsp">添加分类</a>
	</c:if>
	<c:if test="${!empty page.records }">
		<table border="1" width="438">
			<tr>
				<th>序号</th>
				<th>分类名称</th>
				<th>分类描述</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${page.records}" var="c" varStatus="vs">
				<tr class="odd">
					<td>${vs.count}</td>
					<td>${c.name}</td>
					<td>${c.description}</td>
					<td>
					    [<a href="${pageContext.request.contextPath}/manage/addCategory.jsp">添加</a>]
					    [<a href="javascript:updateOneItem('${c.id}')">修改</a>] 
					    [<a href="javascript:delOneItem('${c.id}')">删除</a>]
					</td>
				</tr>
			</c:forEach>
		</table>
		<%@include file="/commons/page.jsp"%>
	</c:if>
</div>
<script type="text/javascript">
	function delOneItem(typeId) {
		var sure = window.confirm("确定删除该选项？");
		if (sure) {
			window.location.href = "${pageContext.request.contextPath}/manage/ManageServlet?op=deleCategory&typeId="
					+ typeId;
		}

	}

	function updateOneItem(typeId) {
		var sure = window.confirm("确定更新？");
		if (sure) {
			window.location.href = "${pageContext.request.contextPath}/manage/ManageServlet?op=updateCategory&typeId="+ typeId;
		}

	}
</script>
</body>
</html>
